package junk;

import classes.Ball;
import processing.core.PApplet;

public class AgingBall extends Ball {
	private int age = 256;
	private int cnt = -1;

	public AgingBall(PApplet p) {
		super(p);
	}

	public void aging() {
		if (cnt <= 0) {
			age++;
		}
	}

	public void cnting() {
		cnt--;
	}

	public void initiate(float x, float y, float speed, float angle, int cnt) {
		trigger(x, y, speed, angle);
		setCnt(cnt);
		setAge(0);
	}

	public void reflect_cnt() {
		if (getX() < getR() || getX() > getP().width - 1 - getR()) {
			cnting();
		}
		if (getY() < getR() || getY() > getP().height - 1 - getR()) {
			cnting();
		}
	}

	public void setAge(int age) {
		this.age = age;
	}

	public void setCnt(int cnt) {
		this.cnt = cnt;
	}

	public int getAge() {
		return age;
	}

	public int getCnt() {
		return cnt;
	}

	public boolean isDead() {
		if (age > 255) {
			return true;
		} else {
			return false;
		}
	}
}
